﻿Public Class KundenauswertungAdapter
    Inherits KundeProjektTaskFormAdapter(Of frmKundenauswertung, KundenauswertungListener)

    Public Sub New()
        MyBase.New(New frmKundenauswertung())
        Me.setComboboxes(form.cbxKunde, Nothing, Nothing)
        Context.KUNDE_PROJEKT_TASK_SERVICE.getObservable.addListener(Me)

        ' init lsvProjekte
        form.lsvProjekte.View = View.Details
        form.lsvProjekte.FullRowSelect = True

        Dim colName As New ColumnHeader()
        colName.Text = "Name"
        colName.Width = 200

        Dim colKosten As New ColumnHeader()
        colKosten.Text = "Kosten"
        colKosten.Width = 100

        form.lsvProjekte.Columns.Add(colName)
        form.lsvProjekte.Columns.Add(colKosten)
    End Sub

    ' kpt-actions:
    Public Overrides Sub onSelectedKundeChanged(ByRef kunde As Kunde)
        MyBase.onSelectedKundeChanged(kunde)
        form.lsvProjekte.SuspendLayout()
        form.lsvProjekte.Items.Clear()
        For Each projekt As Projekt In kunde.projekte
            form.lsvProjekte.Items.Add(New ListViewItem(New String() {projekt.name, projekt.getFormatedKosten()}))
        Next
        form.lsvProjekte.ResumeLayout()
    End Sub


End Class
